home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
-
-
-
- NNNNaaaammmmeeee
- RWTValHashMapIterator<K,T,H,EQ> - Rogue Wave library class
-
- SSSSyyyynnnnooooppppssssiiiissss
- #include<rw/tvhdict.h>
-
-
-
- RWTValHashMap<K,T,H,EQ> m;
- RWTValHashMap<K,T,H,EQ> itr(m);
-
- PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
- IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee....
- OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ffffoooorrrr RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyyIIIItttteeeerrrraaaattttoooorrrr described
- in Appendix A.
-
-
-
-
-
-
- DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr is supplied with Tools 7 to provide an iterator
- interface to RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr that has backward compatibility with
- the container iterators provided in Tools 6. Iteration over an
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp is pseudorandom and dependent on the capacity of the
- underlying hash table and the hash function being used. The only useable
- relationship between consecutive elements is that elements which are
- defined to be equivalent by the equivalence object, EEEEQQQQ, will remain
- adjacent. The current item referenced by this iterator is undefined
- after construction or after a call to rrrreeeesssseeeetttt(((()))). The iterator becomes
- valid after being advanced with either a preincrement or an ooooppppeeeerrrraaaattttoooorrrr(((()))).
- For both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last element will
- return a value equivalent to boolean ffffaaaallllsssseeee. Continued increments will
- return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is called.
-
- PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
- None
-
- EEEExxxxaaaammmmpppplllleeee
- #include<rw/tvhdict.h>
-
-
-
- #include<iostream.h>
- #include<rw/cstring.h>
-
-
- struct silly_h{
-
-
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
-
-
-
- unsigned long operator()(const RWCString& x) const
- { return x.length() * (long)x(0); }
- };
-
-
- int main(){
-
-
-
- RWTValHashMap
- <RWCString,int,silly_h,equal_to<RWCString> > age;
- RWTValHashMapIterator
- <RWCString, int, silly_h, equal_to<RWCString > > itr(age);
-
-
- age.insert(RWCString("John"), 30);
-
-
-
- age.insert(RWCString("Steve"),17);
- age.insert(RWCString("Mark"),24);
-
-
- //Duplicate insertion rejected
-
-
-
- age.insert(RWCString("Steve"),24);
-
-
-
- for(;itr();)
-
-
-
- cout << itr.key() << "'s age is " << itr.value() << endl;
-
-
-
- return 0;
-
-
-
- }
-
-
-
- Program Output (not necessarily in this order)
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
-
-
-
- John's age is 30
- Steve's age is 17
- Mark's age is 24
-
- PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>
-
-
-
- (RWTValHashMap<K,T,H,EQ>&h);
-
-
-
-
-
-
- Creates an iterator for the hashmap hhhh. The iterator begins in an
- undefined state and must be advanced before the first element will be
- accessible.
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
- RWBoolean
- ooooppppeeeerrrraaaattttoooorrrr(((())))();
-
-
- Advances sssseeeellllffff to the next element. Returns ffffaaaallllsssseeee if the iterator has
- advanced past the last item in the container and ttttrrrruuuueeee otherwise.
-
- RWBoolean
- ooooppppeeeerrrraaaattttoooorrrr++++++++();
-
-
- Advances sssseeeellllffff to the next element. If the iterator has been reset or
- just created sssseeeellllffff will now reference the first element. If, before
- iteration, sssseeeellllffff referenced the last association in the multimap, sssseeeellllffff
- will now reference an undefined value and ffffaaaallllsssseeee will be returned.
- Otherwise, ttttrrrruuuueeee is returned. Note: no postincrement operator is provided.
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
- RWTValHashMap<K,T,H,EQ>*
- ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
-
-
- Returns a pointer to the collection being iterated over.
-
- K
- kkkkeeeeyyyy() const;
-
-
- Returns the key portion of the association currently pointed to by sssseeeellllffff.
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-
-
-
- RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
-
-
-
- void
- rrrreeeesssseeeetttt();
- void
- rrrreeeesssseeeetttt(RWTValHashMap<K,T,H,EQ>& h);
-
-
- Resets the iterator so that after being advanced it will reference the
- first element of the collection. Using rrrreeeesssseeeetttt(((()))) with no argument will
- reset the iterator on the current container. Supplying a RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp
- to rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
-
- T
- vvvvaaaalllluuuueeee();
-
-
- Returns the value portion of the association referenced by sssseeeellllffff.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 4444
-
-
-
-